#include <stdio.h>
#include <strings.h>

void normalize(int *array, int length) {
       int k;
       char *str = NULL;
       for (k = length; k > 0; k--) {
               if (array[k] > 9) {
                       array[k] = array[k] - 10;
                       array[k-1]++;
               }
       }
       if (array[0] > 0) {
               printf("%d",array[0]);
       }

       for (k = 1; k <= length; k++) {
               printf("%d",array[k]);
       }
       printf("\n");
}

void processOneCase() {
       int x, y, k;
       int length;
       int array[1000000];
       scanf("%d",&length);
       for (k = 1; k < length+1; k++) {
               scanf("%d %d", &x, &y);
               array[k] = x + y;
       }
       normalize(array,length);
}

void main() {
       int k, empty;
       int cases;
       scanf("%d",&cases);
       for (k = 0; k < cases; k++) {
               getchar();
               processOneCase();
		if (k + 1 != cases) printf("\n");
       }

}
